﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace ApiDay9_l.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class PageController : ControllerBase
    {
        public PageController(IWebHostEnvironment web)
        {
            Web = web;
        }

        public IWebHostEnvironment Web { get; }

        [HttpPost("PageUpd")]
        public IActionResult PageUpd(IFormFile file)
        {
            string mm=Guid.NewGuid().ToString();
            string path=Web.WebRootPath+ @"\img\" + mm + file.FileName;
            using (FileStream fs=System.IO.File.Create(path))
            {
                file.CopyTo(fs);
                fs.Close();
            }
            return Ok("/img/" + mm + file.FileName);
        }



    }
}
